/**
  ******************************************************************************
  * @file    key_task.cpp
  * @author  
  * @version V1.0
  * @date    2017-xx-xx
  * @brief   
  ******************************************************************************
  * @attention
  *
  *
  ******************************************************************************
  */
	
#include	"key_task.h"
#include	"bsp_key.h"
#include	"global_variable.h"

void vTaskKey( void * pvParameters )
{
	cKEY	key1(KEY1_GPIO_PORT, KEY1_PIN);
	uint8_t	key_status;
	
	while(1)                                                  
	{		
		key_status = key1.CheckStatus();
		if(key_status != key1.GetPreStatus())
		{
			do
			{
				key1.StoreStatus(key_status);
				vTaskDelay(10/portTICK_RATE_MS);
				key_status = key1.CheckStatus();				
			}while(key_status != key1.GetPreStatus());
			
			if(key_status == KEY_ON)
			{
				xTaskNotifyGive(xHandleTaskLed);
			}			
		}
		vTaskDelay(100/portTICK_RATE_MS);
	}	
}
